//
// Created by jiangpenghui on 2023/4/19.
//

#include "sort_algorithm.h"
#include "NumStringGen.h"
#include "array_test.h"

int main() {
    adjacent_find_test();

    cout << "============" << endl;
    all_of_test();
    cout << "============" << endl;
    clamp_test();
    cout << "============" << endl;
    vector<int> v1;

    //容器随机赋值
    for (int i = 0; i < 100; ++i) {
        v1.push_back(::rand());
    }

    cout << "Original vector v1 = (";

    for (vector<int>::iterator Iter1 = v1.begin(); Iter1 != v1.end(); Iter1++)
        cout << *Iter1 << " ";
    cout << ")." << endl;

    cout << "============" << endl;

    //v1中每个函数执行MultValue()方法
    for_each(v1.begin(), v1.end(), MultValue<int>(5));

    cout << "Multiplying the elements of the vector v1mod\n "
         << "by the factor 5 gives:\n v1mod2 = ( ";
    for (vector<int>::iterator Iter1 = v1.begin(); Iter1 != v1.end(); Iter1++)
        cout << *Iter1 << " ";
    cout << ")." << endl;

    cout << "============" << endl;
    double roudke = for_each(v1.begin(), v1.end(), Average());

    cout << "The average of the elements of v1 is:\n Average ( roudke ) = "
         << roudke << "." << endl;

    cout << "================" << endl;

    includes_test();

    cout << "=========array_test.h=======" << endl;

    array_equal();

    cout << atomic_ << endl;

    cout << "=======pair ==============" << endl;

    void_make_pair();

    rvalue_test();

    int item_a = 10;
    int *item_p = &item_a;

    int &ref_item = item_a;

    // 编译报错
    // getIntger(item_a);
    // 编译报错
    // getIntger(item_p);
    // 编译报错（但从&& 可以默认转为 &）
    /*   getIntger(ref_item);
       int &&ref = 100;
       cout << " a+ a " << getIntger(ref).b << endl;*/

    /*  // 右值赋值给左值
      auto item = getIntger(2);
      cout << "Intger time is " << item.b << endl;*/

    try {
        // FIXME
        throw "a1";
        divide(6, 0);
    } catch (exception& e) {
        cout << e.what()<< endl;
    }

}
